package main.java.learning.directory.Work.排序.Ac;/**
 * Created by Administrator on 2021/2/18.
 */

import java.util.ArrayList;
import java.util.Arrays;

/**
 * @author aichao
 * @date 2021/2/18
 */
public class BubbleSortDay1 {
    public static void main(String[] args) {
        int[] arrSort = {10,1,35,61,89,36,55};
        bubbleSort(arrSort);
    }
    public static void bubbleSort(int[] arrSort){
        System.out.println("=============排序前============="+ Arrays.toString(arrSort));
        for (int i = 0; i <arrSort.length-1 ; i++) {
            for (int j = 0; j <arrSort.length-i-1 ; j++) {
                if(arrSort[j]>arrSort[j+1]){
                    int tmp = arrSort[j+1];
                    arrSort[j+1]=arrSort[j];
                    arrSort[j] = tmp;
                }
            }
        }

        System.out.println("=============排序后============="+ Arrays.toString(arrSort));
    }
}
